// src/composables/iconUrlByName.ts
const files = import.meta.glob("/src/assets/platform/*.svg", { eager: true });

function baseName(p: string) {
  const f = p.split("/").pop() || "";
  return f.replace(/\.svg$/i, "");
}

const map = new Map<string, string>();
Object.entries(files).forEach(([p, mod]) => {
  const name = baseName(p).toLowerCase(); // 统一转小写
  const url = (mod as any).default as string;
  map.set(name, url);
});

export const iconUrlBy = (name: string) => map.get(name.toLowerCase()) ?? null;
export const iconNames = () => Array.from(map.keys());
